library(oneiric)
library(scater)
library(ggplot2)
library(RColorBrewer)
set.seed(288)
data(oneiric)
map_params
## a b c d x_0 y_0
## [1,] -1.4524975 1.2802377 -0.89194171 2.4186510 0.45164818 -0.11938045
## [2,] -0.9833781 0.7158569 -2.22051348 0.5401524 0.15201547 0.70978265
## [3,] 1.5359136 -0.5865262 0.46922684 1.9351586 -0.80089519 -0.25490827
## [4,] -0.9097808 -0.8748624 2.27694361 0.4794840 0.29575882 -0.73100054
## [5,] 2.6128295 1.2076972 -0.18903700 3.6309333 -1.35852391 0.52502747
## [6,] -2.2279360 1.7791016 -1.20597457 1.0571294 -0.57339884 1.63350853
## [7,] -0.8282720 1.4754709 -0.38121196 -0.8253620 1.16853433 0.08396288
## [8,] -1.3826889 0.4116210 -1.78965910 1.3498485 0.88184490 0.56031956
## [9,] -2.4988707 -2.8057423 0.07558119 -0.2581050 0.48210929 -1.78630243
## [10,] -0.9108967 4.3691958 -0.10709005 2.5931729 -1.00821722 -0.38977567
## [11,] -2.0506795 1.1691831 -1.40869336 1.2404386 -0.61605783 1.97442209
## [12,] -1.7135684 -0.1199584 0.48353594 1.2159022 1.18212102 -0.66240489
## [13,] -1.3700543 -0.6228237 0.04649359 1.4258482 -1.00970676 1.28502390
## [14,] -2.5149806 -4.2115682 1.35684939 1.6831248 0.05273502 -0.12617619
## [15,] 2.0762965 -0.2755917 -0.76867673 1.2246233 -0.90646219 0.54479486
## [16,] -0.5116489 -1.0998629 -0.75110047 0.5155583 0.05990936 -0.26377246
## [17,] -4.7771668 4.3060377 -1.50604446 -0.2426992 0.94797294 2.61778723
## [18,] -2.3034036 -0.2044303 -2.31393112 1.5616273 -0.05644338 -0.36995731
## [19,] -0.4071411 0.7486259 -0.41520969 1.2877298 -0.28991360 1.01219584
## [20,] -1.1977801 1.0634716 -0.52625141 1.1745420 -0.83615997 -0.83545511
## [21,] -1.1890503 -1.6608322 3.49584000 1.1665141 0.73463956 -1.78704136
## [22,] -1.1512296 -1.7267131 0.38683127 -0.7195584 0.75264573 -0.65461937
## [23,] -1.0600826 -0.9489989 0.08094950 -0.8479636 1.58579695 -0.06424196
## [24,] 1.1496231 1.0198538 -1.92018938 -0.3317371 -0.53936695 0.59072867
## [25,] 0.2651844 2.4037982 0.49374343 -0.2448217 0.32016818 -0.33049077
## [26,] 1.6048797 0.2167301 0.44938604 2.4042743 -0.11351876 -0.07733417
## [27,] -0.1355331 -1.0296461 1.09688996 0.8760724 -0.29289105 -0.93654977
## [28,] 2.1461147 -4.5485150 0.02623263 0.7284910 -0.97357690 -0.13225379
## [29,] 0.9000000 -0.6013000 2.00000000 0.5000000 -0.72000000 -0.64000000
## [30,] 0.5535363 2.2079160 0.36159485 1.8782757 -0.73090825 -0.16021286
## [31,] 0.5579728 -0.5012534 3.53268415 -0.7956229 -0.14021484 -0.51037642
## [32,] -1.4025020 -0.4331542 -0.25024455 0.2950250 -0.13910644 -1.23359252
## [33,] 3.3379829 -2.3800425 0.43428288 3.0860127 -1.23075426 -1.92820430
## [34,] 1.1540912 -1.7535453 0.08302577 0.8090087 -0.49286072 -0.17190885
## [35,] -2.1114611 1.9888498 -0.64616627 0.7607303 0.39476142 0.41183028
## [36,] -1.6844748 1.2920278 1.96527333 0.4804940 0.06424053 0.66946574
sim_ter <- paste0(system.file(package = "oneiric"), "/inst/extdata/")
dir(sim_ter)
## character(0)
output <- "/Users/martinp4/Documents/Cedars/Oneiric/simulations/"
circle <- simulate_spatial(n_cells = 5000,
n_territories = 5,
n_samples = 12,
pattern = "circle",
expanse = c(0.1, 0.3))
rod <- simulate_spatial(n_cells = 5000,
n_territories = 5,
n_samples = 12,
pattern = "rod",
width_range = c(0.0, 0.1),
length_range = c(0.2, 0.5))
chaos_map <- simulate_spatial(n_cells = 5000,
n_samples = 12,
pattern = "chaos",
expanse = 0.02)
circles <- do.call("rbind", circle)
circles$Territory <- as.factor(circles$Territory)
g <- ggplot(circles, aes(x = x, y = y, col = Territory)) +
geom_point(size = 0.5) +
theme_bw() +
scale_color_brewer(palette = "Spectral") +
facet_wrap(~sample) +
guides(colour = guide_legend(
override.aes = list(size = 5)))
print(g)
Circular Territories
rods <- do.call("rbind", rod)
rods$Territory <- as.factor(rods$Territory)
g <- ggplot(rods, aes(x = x, y = y, col = Territory)) +
geom_point(size = 0.5) +
theme_bw() +
scale_color_brewer(palette = "Spectral") +
facet_wrap(~sample) +
guides(colour = guide_legend(
override.aes = list(size = 5)))
print(g)
Rod Territories
chaos <- do.call("rbind", chaos_map)
chaos$Territory <- as.factor(chaos$Territory)
g <- ggplot(chaos, aes(x = x, y = y, col = Territory)) +
geom_point(size = 0.5) +
theme_bw() +
scale_color_brewer(palette = "Spectral") +
facet_wrap(~sample) +
guides(colour = guide_legend(
override.aes = list(size = 5)))
print(g)
Tinkerbell Map Territories
circle <- simulate_cells(circle,
cell_composition = 2,
n_genes = 2000,
seed = 1729)
rod <- simulate_cells(rod,
cell_composition = 2,
n_genes = 2000,
seed = 1729)
chaos <- simulate_cells(chaos_map,
cell_composition = 2,
n_genes = 2000,
seed = 1729)
export_simulation(spatial = circle$spatial,
cells = circle$counts,
out_dir = output,
file_tag = "circle_spatial_territories")
## NULL
export_simulation(spatial = rod$spatial,
cells = rod$counts,
out_dir = output,
file_tag = "rod_spatial_territories")
## NULL
export_simulation(spatial = chaos$spatial,
cells = chaos$counts,
out_dir = output,
file_tag = "chaos_spatial_territories")
## NULL
circular_layer <- simulate_spatial(n_cells = 5000,
n_territories = 1,
n_samples = 12,
pattern = "circle",
expanse = c(0.4, 0.5),
layer = 5)
circular_layer_counts <- simulate_cells(circular_layer,
as_layer = TRUE,
cell_composition = 2)
circles <- do.call("rbind", circular_layer_counts$spatial)
circles$Territory <- as.factor(circles$Territory)
g <- ggplot(circles, aes(x = x, y = y, col = Territory)) +
geom_point(size = 0.5) +
theme_bw() +
scale_color_brewer(palette = "Spectral") +
facet_wrap(~sample) +
guides(colour = guide_legend(
override.aes = list(size = 5)))
print(g)
## Warning in RColorBrewer::brewer.pal(n, pal): n too large, allowed maximum for palette Spectral is 11
## Returning the palette you asked for with that many colors
## Warning: Removed 617 rows containing missing values (`geom_point()`).
export_simulation(spatial = circular_layer_counts$spatial,
cells = circular_layer_counts$counts,
out_dir = output,
file_tag = "layered_spatial_territories")
## NULL
chaos_layer <- simulate_spatial(n_cells = 5000,
n_samples = 12,
pattern = "chaos",
expanse = 0.1,
layer = 5)
chaos_layer_counts <- simulate_cells(chaos_layer,
as_layer = TRUE,
cell_composition = 2)
chaos <- do.call("rbind", chaos_layer_counts$spatial)
chaos$Territory <- as.factor(chaos$Territory)
g <- ggplot(chaos, aes(x = x, y = y, col = Territory)) +
geom_point(size = 0.5) +
theme_bw() +
scale_color_brewer(palette = "Spectral") +
facet_wrap(~sample) +
guides(colour = guide_legend(
override.aes = list(size = 5)))
print(g)
## Warning in RColorBrewer::brewer.pal(n, pal): n too large, allowed maximum for palette Spectral is 11
## Returning the palette you asked for with that many colors
## Warning: Removed 44 rows containing missing values (`geom_point()`).
export_simulation(spatial = chaos_layer_counts$spatial,
cells = chaos_layer_counts$counts,
out_dir = output,
file_tag = "tinker_spatial_territories")
## NULL